<?php
/**
 * Created by YuanXiShop.
 * User: YuanXi
 * Date: 2021/6/1 0001
 * Time: 18:06
 */

namespace admin;
use controllers\BaseControllers;

class Admin extends BaseControllers
{
    public function __construct()
    {
        $loader = new \Twig\Loader\FilesystemLoader(TEMPDIR.'/app/views/admin');
        $this->twig = new \Twig\Environment($loader, [
            //'cache' => '/path/to/compilation_cache',
        ]);
        $this->assign('session',$_SESSION);
        if(!ew_login('admin')){
            $this->error('/admin/login','你还没登陆，请先登陆。。。');
        }
    }
    protected function display($template){
        $url = getCurUrl();
        $this->assign('url',$url.'/app/views/admin/resource');//自己模板下的CSS、JS、images
        $this->assign('public',$url.'/app/views/public');//所有模板公共的前端CSS、JS、images
        $this->assign('res',$url.'/uploads');//文件上传资源
        echo $this->twig->render($template.'.html', $this->data);
    }
}